﻿Imports System.Data
Imports System.Data.OleDb
Partial Class AddDiscussions
    Inherits System.Web.UI.Page

    Protected Sub Page_Load(sender As Object, e As System.EventArgs) Handles Me.Load
       
    End Sub

    Protected Sub btnSubmit_Click(sender As Object, e As System.EventArgs) Handles btnSubmit.Click
        Dim oleDbConn As New OleDb.OleDbConnection(ConfigurationManager.ConnectionStrings("myFirstDatabase").ConnectionString)
        Dim SqlString As String = "Insert into tblDiscussions(Topic,Author,Category,SubmittedDate) Values (@f1,@f2,@f3,@f4)"
        Dim cmd As OleDbCommand = New OleDbCommand(SqlString, oleDbConn)
        Dim SubmittedDate As DateTime = Now()
        Dim format As String = "ddd MMM yyyy"
        cmd.CommandType = CommandType.Text
        cmd.Parameters.AddWithValue("@f1", txtTopic.Text)
        cmd.Parameters.AddWithValue("@f2", User.Identity.Name)
        ' cmd.Parameters.AddWithValue("@f2", txtAuthor.Text)
        cmd.Parameters.AddWithValue("@f3", DDLCategories.SelectedValue)
        cmd.Parameters.AddWithValue("@f4", SubmittedDate.ToString(format))
        oleDbConn.Open()
        cmd.ExecuteNonQuery()
        Response.Redirect("DiscussConfirm.aspx")
    End Sub
End Class
